<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp" %>
<script type="text/javascript">

function del(e,id){
	if(confirm("附件操作不可恢复,确认删除吗?")){
		var f=false;
		$.ajax({
			  async:false,
			  type: 'POST',
			  url: "<s:property value='contextPath'/>/attach/del.do?id="+id,
			  dataType: "json",
			  success: function(data) {
					  	f = data.flag;
					  	if(f){
					  		//alert("删除成功");
					  		$(e).parent().remove();
					  	}
					}		
				,
				error:function(data){
				}
			}); 
		
	}
	
}

function dosel(){
	var form1 = document.form1;
	form1.action = "<s:property value='contextPath'/>/cs/add.do";
	form1.submit();
}


function exportStore(){
	var form1 = document.form1;
	form1.action = "<s:property value='contextPath'/>/cs/exportStore.do";
	form1.submit();
}

function doclear(){
	$("#shop_id").val("");
	$("#shop_name").val("");
	$("#shopUser_tr").empty();
	$(".d_tr").remove();
	$("#d_tab1").hide();
	$("#d_tab2").hide();
	
}

function selectShop(){
	window.open("<s:property value='contextPath'/>/system/treaty/selectCheckStockShop.do", "newwindow", "height=800, width=800, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
function selectShopCallBack(num_,name_,id_){
	if($("#shop_id").val()!=id_){
		$("#shop_id").val(id_);
		$("#shop_name").val(name_);
		//$("#shopUser_tr").children('font').remove();
		dosel();
	}
	
}
</script>

	<input type="hidden" name="redirectUrl" value='<s:property value='redirectUrl'/>'/>
	<input type="hidden" id="operate" name="operate" value='save'/>
	<input type="hidden" name="entity.id" value='<s:property value='entity.id'/>'/>
	
	<table width="100%" border="0" cellpadding="1" cellspacing="1">
		<tr>
			<td class="left-td-width-bg">
				店名：
			</td>
			<td width="45%" class="bline" align="left">
				<input type="hidden" id="shop_id" name="entity.shop.id" value="<s:property value='entity.shop.id'/>">
				<input name="entity.shop.shopName"  dataType="Require" msg="请选择销售店 "  id="shop_name" class="input_send_readOnly_92" readonly="readonly" value="<s:property value='entity.shop.shopName'/>" dataType="Require" msg="店铺必须选择"/>
				<a href="javascript:selectShop()"><img src="${contextPath}/images/chakan.gif" alt="选择" width="16" height="18" border="0" /></a>
			</td>
			<td class="left-td-width-bg">
				驻店顾问：
			</td>
			<td width="30%" class="bline" align="left" id="shopUser_tr">
				<%-- <jysz:autocompleter cssClass="input_ajax" callBackFun="dosel" name="entity.shopUser.realName" classType="com.jysz.certificate.persistence.model.system.User" displayFields="realName" fieldMapping="{'userId':'id'}" >
				</jysz:autocompleter> --%>
	           	<!-- dataType="Require" msg="金融机构必须选择" -->
	           	<s:if test="orgList!=null&&orgList.size>0">
	           		<s:select id="shopUser" name="entity.shopUser.id" list="orgList" listKey="objectId" listValue="name" value="entity.shopUser.id"   theme="simple"></s:select>
	           	</s:if>
	           	
			</td>
		</tr>
		<tr>
			<td class="left-td-width-bg">
				区域经理：
			</td>
			<td width="30%" class="bline" align="left">
				<input type="hidden" name="entity.areaManager.id" value="<s:property value='entity.areaManager.id'/>">
				<input name="entity.areaManager.realName" class="input_send_readOnly_92" readonly="readonly" value="<s:property value='entity.areaManager.realName'/>"/>
			</td>
			<td class="left-td-width-bg">
				发起人：
			</td>
			<td width="45%" class="bline" align="left">
				<input type="hidden" name="entity.sponsor.id" value="<s:property value='entity.sponsor.id'/>">
				<input name="entity.sponsor.realName" class="input_send_readOnly_92" readonly="readonly" value="<s:property value='entity.sponsor.realName'/>"/>
			</td>
		</tr>
		<tr>
			<td class="left-td-width-bg">
				盘库方式：
			</td>
			<td width="30%" class="bline" align="left">
				<input type="radio" name="entity.live" <s:if test="entity.live">checked="checked"</s:if> value="true">现场 &nbsp;&nbsp;
				<input type="radio" name="entity.live" <s:if test="!(entity.live)">checked="checked"</s:if> value="false">非现场
			</td>
			<td class="left-td-width-bg">
				盘库来源：
			</td>
			<td width="45%" class="bline" align="left">
				<input type="hidden" name="entity.source" value="<s:property value="entity.source"/>" />
				<s:property value="entity.source.name"/>
			</td>
		</tr>
		
		<tr style="padding-top: 20px">
			<td class="bline" colspan="4" align="center">
				<input type="button" onclick="doclear()" value="" class="btn_rest"/>
				<!-- <input type="button" name="btn_submit" id="checkin" value="" class="btn_sponsor"/> -->
				<input type="button" name="btn_submit" id="save" value="" class="btn_temporary"/>
			</td>
		</tr>
	</table>

	<!-- 库存清单开始 -->	
	<s:if test="page!=null&&page.result!=null">
		<br/>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" id="d_tab1">
		  <tr>
		    <td height="25" align="left"><font color="#0066CC"><strong>库存清单：</strong></font></td>
		    <td height="25" align="right">
			    <s:if test="entity!=null&&entity.id!=null">
			    	 &nbsp;<a href="javascript:exportStore();"><img src="${contextPath}/images/export.png" alt="导出"  /></a>
			    </s:if>
		    </td>
		  </tr>
		</table> 
		<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC" id="d_tab2">
		  <tr>
		    <td width="4%" class="top-td-width-bg">序号</td>
		    <td width="9%" class="top-td-width-bg">渠道</td>
		    <td width="10%" class="top-td-width-bg">金融机构</td>
		    <td width="10%" class="top-td-width-bg">合格证号</td>
		    <td width="10%" class="top-td-width-bg">车架号</td>
		    <td width="10%" class="top-td-width-bg">发动机号</td>
		    <td width="10%" class="top-td-width-bg">车型</td>
		    <td width="8%" class="top-td-width-bg">单价</td>
		    <td width="10%" class="top-td-width-bg">入库日期</td>
		    <td width="9%" class="top-td-width-bg">状态</td>
		    <td width="10%" class="top-td-width-bg">备注</td>
		  </tr>
		  <s:if test="page.result.size>0">
		  	<s:iterator value="page.result" status="stx" >
			<tr class="d_tr" height="26" align="center" bgcolor="#FFFFFF" onmousemove="javascript:this.bgColor='#FCFDEE';" onmouseout="javascript:this.bgColor='#FFFFFF';"> 
			 	<td align="center"><s:property value="#stx.index+1"/></td>
			    <td align="center"><s:property value="brand.name"/></td>
			    <td align="center"><s:property value="financial.name"/></td>
			    <td align="center"><s:property value="certificationNum"/></td>
			    <td align="center"><s:property value="chassis"/></td>
			    <td align="center"><s:property value="engine"/></td>
			    <td align="center"><s:property value="motorcycleType"/></td>
			    <td align="center"><s:property value="formatAmount(supplyPrice)"/></td>
			    <td align="center"><s:date name="warehouseDate" format="yyyy-MM-dd"/></td>
			    <td align="center"><s:property value="state.name" /></td>
			    <td align="center"><s:property value="remarks" /></td>
			</tr>
		</s:iterator>
		  </s:if>
		  <s:else>
		  	<tr height="26" align="center" bgcolor="#FFFFFF" id="none_tr">
		  		<td colspan="11"><font color="red"><s:property value="entity.shop.shopName"/> 店铺中没有在库的合格证,请更换店铺</font></td>
		  	</tr>
		  </s:else>
		 
		<tr bgcolor="#F9FCEF"> 
		 <td height="36" colspan="11" align="center">
				<%@ include file="/WEB-INF/view/common/pagination.jsp"%>
		 </td>
		</tr>
		</table>
		<br/>
	</s:if>